<?php 
require_once("conexao.php");

$idaluno = isset($_GET['id_aluno']) ? $_GET['id_aluno'] :  "";


//$idaluno = 2;

if(!empty($idaluno)){		 	

$senha = sha1($senha);

		$sql = pg_query($bd,"SELECT d.id,
									d.nome as nome_disciplina, 
									p.nome as professor,
									p.email as email_prof,
									m.ano,
									m.semestre,
									d.tipo,
									t.local,
									t.horario_aula as horario,
									d.cargahoraria as CargaHoraria

							FROM siscad.matricula as m 
								join siscad.turma as t on t.id = m.id_turma
								join siscad.disciplina as d on d.id = t.id_disciplina
								join siscad.professor as p on p.id  = t.id_professor
								WHERE m.id_aluno=" . $idaluno) or die("ERRO NO COMANDO SQL");

		
		$result =array();
		
		while($r = pg_fetch_array($sql)){
		
		//print_r($r);


		$result[] = array("id" => $r['id'], 
						   "nome_disciplina" => $r['nome_disciplina'],
						   "professor" => $r['professor'],
						   "email_prof" => $r['email_prof'],						  
						   "ano" => $r['ano'],
						   "semestre" => $r['semestre'],
						   "tipo" => $r['tipo'],
						   "local" => $r['local'],
						   "horario" => $r['horario'],
						   "cargahoraria" => $r['cargahoraria'],
						   ); 
		}

		if(empty($result)){
			$json = array("status" => 0, "msg" => "Sem Matriculas, para esse aluno");	
		}else{
			$json = array("status" => 1, "info" => $result);
		}
		

}else{
		$json = array("status" => 0, "msg" => "Usuario vazio");
}  	

@mysql_close($conn);

/* Output header */
header('Content-type: application/json');
echo json_encode($json);
?>